home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Stickerpedia Stickerbook
/
Stickerbook.iso
/
pc
/
DATA
/
behaviours.cxt
/
00003_Script_ [ global ] General Field Input Control
< prev
next >
Wrap
Text File
|
2003-03-23
|
5KB
|
202 lines
global oMarvin, gShowingAlert, oSpr
property pMyName
property spriteNum
property pMaxNumOfChars
property pLegalInputSymbol
property pLegalInput
property pOkSprite
property pAllowAlert
property pMakeEditableOnClick
property pMyMember
property pMakeEditableOnBegin
property pTabToNextField
property pTabOrderPosition
property pEmptyOnBegin
property pFirstEditableSprite
on beginSprite me
-- set pMyName = SprToFullName (oMarvin, the spritenum of me)
if pOkSprite = -1 then set pOkSprite = spriteNum -1
pMyMember = sprite(spriteNum).member
if pMakeEditableOnBegin then sprite(spriteNum).editable = 1
if pLegalInputSymbol = #letters then
pLegalInput = "qwertyuiopasdfghjklzxcvbnm_"
else if pLegalInputSymbol = #numbers then
pLegalInput = "0123456789"
else
pLegalInput = "qwertyuiopasdfghjklzxcvbnm_0123456789 "
end if
if pEmptyOnBegin then sprite(spriteNum).member.text = ""
end
on prepareFrame me
-- if pFirstEditableSprite then
-- sprite(spriteNum).editable = 1
-- pFirstEditableSprite = 0
-- end if
end
on selectAll me
numOfCharsInMe = sprite(spriteNum).member.text.length
put numOfCharsInMe
the selStart = 1
the selEnd = 1
end
on mouseDown me
if pMakeEditableOnClick then sprite(spriteNum).editable = 1
pass
end
on keyUp me
dontpassevent
end
on keyDown me
if gShowingAlert and not pAllowAlert then exit
if the key = RETURN and pOkSprite > 0 then
-- modify oSpr, pOkSprite, #dwn
-- updatestage
-- startTimer
-- repeat while the timer < 10
-- end repeat
sendSprite pOkSprite, #msUp
-- updatestage
-- sendSprite pOkSprite, #mouseUp
exit
end if
theKey = the key
theKeyCode = the keycode
if pLegalInput contains theKey then
-- a key was pressed that is allowed to appear in the text field:
if sprite(spriteNum).member.text.length >= pMaxNumOfChars then
beep
else
pass
end if
else
-- it's a key that isn't allowed or it's a function key:
case theKeyCode of
51: -- backspace key:
if the selStart = 0 and the selEnd = pMaxNumOfChars then
set the text of the member of sprite spriteNum = ""
end if
pass
48: -- tab key:
if pTabToNextField then
-- take control of which text field will be highlighted:
deActivate me
sendAllSprites #activate, (pTabOrderPosition + 1)
else
-- leave to however the sprites are ordered
pass
end if
123,124: -- arrow keys:
pass
end case
end if
end
on activate me, tabOrderPosition
if pTabOrderPosition = tabOrderPosition then
sprite(spriteNum).editable = 1
sendAllSprites #fieldWasActivated, pTabOrderPosition
end if
end
on deActivate me
sprite(spriteNum).editable = 0
end
on getPropertyDescriptionList me
set tabOrderPositionList = [#na,1,2,3,4,5,6,7,8,9,10]
set maxCharsList = [#1,#2,#3,#4,#5,#6,#7,#8,#9,#10,#11,#12,#13,#14,#15,#16,#17,#18,#19,#20]
set legalInputList = [#letters,#numbers,#both]
set description = [:]
addProp description, #pMakeEditableOnBegin, [#comment: "Make editable on beginSprite", #format: #boolean, #default: 0]
addProp description, #pFirstEditableSprite, [#comment: "This sprite to be editable by default", #format: #boolean, #default: 0]
addProp description, #pMakeEditableOnClick, [#comment: "Make editable on click", #format: #boolean, #default: 1]
addProp description, #pEmptyOnBegin, [#comment: "Empty text field on beginsprite", #format: #boolean, #default: 1]
addProp description, #pTabToNextField, [#comment: "Tab to next field", #format: #boolean, #default: 0]
addProp description, #pTabOrderPosition, [#comment: "Tab order", #format: #integer, #default: 0, #range: tabOrderPositionList]
addProp description, #pAllowAlert, [#comment: "Allow input into this field when showing alert?", #format: #boolean, #default: 0]
addProp description, #pOkSprite, [#comment: "Send #mouseDown on RETURN to sprite (0 for none, -1 for sprite in channel below):" & return, ¨
#format: #integer, #range: [#min:-1,#Max:120], #default: 0]
addProp description, #pMaxNumOfChars, [#comment: "Maximum number of chars:", #format: #integer, #default: 12, #range: maxCharsList]
addProp description, #pLegalInputSymbol, [#comment: "Legal input: " & RETURN & "Letters = qwertyuiopasdfghjklzxcvbnm_ , " & "numbers = 0123456789" , ¨
#format: #symbol, #range: legalInputList, #default: #both]
return description
end